﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
using Verse.AI;

namespace Miao.Stand
{
    public class JobDriver_StandCoverMaster : JobDriver
    {
        StandPawn standPawn
        {
            get
            {
                return pawn as StandPawn;
            }
        }
        public override bool TryMakePreToilReservations(bool errorOnFailed)
        {
            return true;
        }
        protected override IEnumerable<Toil> MakeNewToils()
        {
            yield return CoverMaster();
        }
        public override void Notify_DamageTaken(DamageInfo dinfo)
        {
            this.startTick = 0;
            base.Notify_DamageTaken(dinfo);
        }

        private Toil CoverMaster()
        {
            Toil toil = new Toil();
            toil.tickAction += standPawn.SetStandCover;
            toil.defaultCompleteMode = ToilCompleteMode.Never;
            toil.FailOn(() => !standPawn.ghostFollow);
            return toil;
        }

    }
}
